﻿namespace WMS6.Web.Inbound
{
    using System;
    using System.Collections.Generic;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;
    using WMS6.Web.BaseInfoDetailServiceRef;
    using WMS6.Web.BaseInfoServiceRef;
    using WMS6.Web.InboundDetailServiceRef;
    using WMS6.Web.LoginServiceRef;
    using WMS6.Web.UserControls;

    public class ReceivingDetail : BasePage
    {
        protected HtmlAnchor aReceivedQty;
        protected Button btnCancel;
        protected Button btnSave;
        protected Button btnSaveContinue;
        protected CheckBox chb0;
        protected CheckBox CheckBox1;
        protected DropDownList ddlFreezeCode;
        protected DropDownList ddlReasonCode;
        protected DropDownList ddlStatus;
        protected DropDownList ddlUomID;
        protected DropDownList DropDownList1;
        protected DropDownList DropDownList2;
        protected HtmlForm F4023;
        protected HtmlInputHidden hdncalendarFlag;
        protected HtmlInputHidden hdnCube;
        protected HtmlInputHidden hdnDataFormat;
        protected HtmlInputHidden hdnDefaultUom;
        protected HiddenField hdnExpiryDate;
        protected HiddenField hdnExternal;
        protected HtmlInputHidden hdnFormart;
        protected HtmlInputHidden hdnFrom;
        protected HtmlInputHidden hdnGrossWgt;
        protected HiddenField hdnLot1;
        protected HiddenField hdnLot10;
        protected HiddenField hdnLot2;
        protected HiddenField hdnLot3;
        protected HiddenField hdnLot4;
        protected HiddenField hdnLot5;
        protected HiddenField hdnLot6;
        protected HiddenField hdnLot7;
        protected HiddenField hdnLot8;
        protected HiddenField hdnLot9;
        protected HtmlInputHidden hdnNetWgt;
        protected HtmlInputHidden hdnOwnerID;
        protected HiddenField hdnProductDate;
        protected HtmlInputHidden hdnReceiptID;
        protected HtmlInputHidden hdnType;
        protected HtmlInputHidden hdnUomValue;
        protected Label Label1;
        protected Label Label10;
        protected Label Label11;
        protected Label Label2;
        protected Label Label3;
        protected Label Label4;
        protected Label Label5;
        protected Label Label6;
        protected Label Label7;
        protected Label lblASNDetail;
        protected Label lblCaseID;
        protected Label lblCube;
        protected Label lblExpectedQty;
        protected Label lblFreezeCode;
        protected Label lblGrossWgt;
        protected Label lblHadReceivedQty;
        protected Label lblHeight;
        protected Label lblLength;
        protected Label lblLoc;
        protected Label lblLpnID;
        protected Label lblMsg;
        protected Label lblNetWgt;
        protected Label lblPackID;
        protected Label lblPoID;
        protected Label lblReasonCode;
        protected Label lblReceiptDate;
        protected Label lblReceiptLineID;
        protected Label lblReceivedQty;
        protected Label lblRemark;
        protected Label lblSkuDescr;
        protected Label lblSkuID;
        protected Label lblStatus;
        protected Label lblUdf04;
        protected Label lblUdf09;
        protected Label lblUdf1;
        protected Label lblUdf10;
        protected Label lblUdf2;
        protected Label lblUdf3;
        protected Label lblUdf5;
        protected Label lblUdf6;
        protected Label lblUdf7;
        protected Label lblUdf8;
        protected Label lblUomID;
        protected Label lblVendorID;
        protected Label lblWidth;
        protected LotAtrributeCtrl LotAtrributeCtrl1;
        protected HtmlLink mycss;
        protected Label one1;
        protected Label one2;
        protected Label one3;
        protected ScriptManager ScriptManager1;
        protected TextBox TextBox1;
        protected TextBox TextBox10;
        protected TextBox TextBox11;
        protected TextBox TextBox2;
        protected TextBox TextBox4;
        protected TextBox TextBox5;
        protected TextBox TextBox6;
        protected TextBox txtCaseID;
        protected TextBox txtCube;
        protected TextBox txtExpectedQty;
        protected TextBox txtGrossWgt;
        protected TextBox txtHadReceivedQty;
        protected TextBox txtHeight;
        protected TextBox txtLength;
        protected TextBox txtLoc;
        protected TextBox txtLpnID;
        protected TextBox txtNetWgt;
        protected TextBox txtPackID;
        protected TextBox txtPoID;
        protected TextBox txtReceiptDate;
        protected TextBox txtReceiptLineID;
        protected TextBox txtReceivedQty;
        protected TextBox txtRemark;
        protected TextBox txtSkuDescr;
        protected TextBox txtSkuID;
        protected TextBox txtUdf1;
        protected TextBox txtUdf10;
        protected TextBox txtUdf2;
        protected TextBox txtUdf3;
        protected TextBox txtUdf4;
        protected TextBox txtUdf5;
        protected TextBox txtUdf6;
        protected TextBox txtUdf7;
        protected TextBox txtUdf8;
        protected TextBox txtUdf9;
        protected TextBox txtVendorID;
        protected TextBox txtWidth;

        private void BindData2UomList(string packID)
        {
            try
            {
                List<WMS6.Web.CommonMethodServiceRef.UomList> uomList = CommoneMethodServiceClientProxy.GetInstance().GetUomListByPackID(packID);
                if ((uomList != null) && (uomList.Count > 0))
                {
                    base.BindUomList2DDL(this.ddlUomID, uomList);
                    this.ViewState["UOMLIST"] = uomList;
                    this.CalcSkuWgtCube();
                }
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("F4100_030") + ex.Message;
                this.txtPackID.Focus();
            }
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            base.Response.Redirect(string.Format("Receiving.aspx?from={0}&detail={1}&ID={2}", base.UrlEncode(this.hdnFrom.Value), "2", base.UrlEncode(this.hdnReceiptID.Value.Trim())));
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string result = this.ManualReceiving();
                if (!(string.IsNullOrEmpty(result) || !(result != "msg")))
                {
                    ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", " <script type=\"text/javascript\" >$.unblockUI(); </script>", false);
                    base.Response.Redirect(string.Format("Receiving.aspx?from={0}&detail={1}&ID={2}", base.UrlEncode(this.hdnFrom.Value), "2", base.UrlEncode(this.hdnReceiptID.Value.Trim())));
                }
                else if (result != "msg")
                {
                    this.lblMsg.Text = base.GetGlobalMsgResource("F4200_024");
                    this.lblMsg.Visible = true;
                }
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = ex.Message;
                this.lblMsg.Visible = true;
            }
            ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", " <script type=\"text/javascript\" >$.unblockUI(); </script>", false);
        }

        protected void btnSaveContinue_Click(object sender, EventArgs e)
        {
            try
            {
                string result = this.ManualReceiving();
                if (!string.IsNullOrEmpty(result) && (result != "msg"))
                {
                    string receiptID = base.Request.QueryString["rid"].ToString();
                    ReceiptDetailInfo receiptDetail = InboundDetailServiceClientProxy.GetInstance().GetNextUncompletedReceiptDetailInfo(receiptID);
                    if (!((receiptDetail == null) || string.IsNullOrEmpty(receiptDetail.ReceiptID)))
                    {
                        this.LotAtrributeCtrl1.ClearControl();
                        this.SetReceiptDetailInfo2Form(receiptDetail);
                        this.LotAtrributeCtrl1.LoadData(this.txtSkuID.Text.Trim(), this.hdnOwnerID.Value, this.LotAtrributeCtrl1.ClientID.ToString(), true, 4);
                    }
                    else
                    {
                        this.btnSave.Enabled = false;
                        this.btnSaveContinue.Enabled = false;
                        this.ddlStatus.SelectedValue = "ReceivedComplete";
                        this.lblMsg.Text = receiptID + "已经收货完成!";
                        this.lblMsg.Visible = true;
                    }
                }
                else if (result != "msg")
                {
                    this.lblMsg.Text = base.GetGlobalMsgResource("F4200_024");
                    this.lblMsg.Visible = true;
                }
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = ex.Message;
                this.lblMsg.Visible = true;
            }
            ScriptManager.RegisterStartupScript(this.Page, base.GetType(), "", " <script type=\"text/javascript\" >$.unblockUI(); </script>", false);
        }

        private void CalcSkuWgtCube()
        {
            List<WMS6.Web.CommonMethodServiceRef.UomList> uomList = this.ViewState["UOMLIST"] as List<WMS6.Web.CommonMethodServiceRef.UomList>;
            float uomQty = base.GetUomQtyByUomList(this.ddlUomID.SelectedValue, uomList);
            this.hdnUomValue.Value = uomQty.ToString();
            if (uomQty > 0f)
            {
                float cube = string.IsNullOrEmpty(this.hdnCube.Value.Trim()) ? 0f : float.Parse(this.hdnCube.Value.Trim());
                float grossWgt = string.IsNullOrEmpty(this.hdnGrossWgt.Value.Trim()) ? 0f : float.Parse(this.hdnGrossWgt.Value.Trim());
                float netWgt = string.IsNullOrEmpty(this.hdnNetWgt.Value.Trim()) ? 0f : float.Parse(this.hdnNetWgt.Value.Trim());
                float receivedQty = string.IsNullOrEmpty(this.txtReceivedQty.Text.Trim()) ? 0f : float.Parse(this.txtReceivedQty.Text.Trim());
                this.txtCube.Text = base.GetPreferenceDigit((float) ((cube * uomQty) * receivedQty));
                this.txtGrossWgt.Text = base.GetPreferenceDigit((float) ((grossWgt * uomQty) * receivedQty));
                this.txtNetWgt.Text = base.GetPreferenceDigit((float) ((netWgt * uomQty) * receivedQty));
            }
            else
            {
                this.txtCube.Text = base.GetPreferenceDigit(0);
                this.txtGrossWgt.Text = base.GetPreferenceDigit(0);
                this.txtNetWgt.Text = base.GetPreferenceDigit(0);
            }
        }

        protected void ddlUomID_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.CalcSkuWgtCube();
        }

        private ReceiptDetailInfo GetReceiptDetailInfoFromForm()
        {
            DateTime dt = DateTime.Now;
            ReceiptDetailInfo receiptDetail = base.DataEntityViewState as ReceiptDetailInfo;
            ReceiptLotInfo receiptLotInfo = new ReceiptLotInfo {
                LotAttr01 = "",
                LotAttr02 = "",
                LotAttr03 = "",
                LotAttr04 = "",
                LotAttr05 = "",
                LotAttr06 = "",
                LotAttr07 = "",
                LotAttr08 = "",
                LotAttr09 = "",
                LotAttr10 = ""
            };
            List<Control> lotControls = this.Session["LotAttributeControls"] as List<Control>;
            this.Session["LotAttributeControls"] = null;
            if ((lotControls != null) && (lotControls.Count > 0))
            {
                foreach (Control ctrl in lotControls)
                {
                    Exception ex;
                    DateTime CS00003;
                    string temp = "";
                    object obj = base.Request.Form[this.LotAtrributeCtrl1.ClientID.ToString() + "$" + ctrl.ID.ToString()];
                    if (obj != null)
                    {
                        temp = obj.ToString().Trim();
                    }
                    if (ctrl.ID == "txtProduct")
                    {
                        try
                        {
                            if (!string.IsNullOrEmpty(temp.Trim()))
                            {
                                CS00003 = new DateTime();
                                if (DateTime.Parse(temp) != CS00003)
                                {
                                    receiptLotInfo.ProduceDate = DateTime.Parse(temp);
                                }
                                else
                                {
                                    this.lblMsg.Text = "输入的时间格式不正确！";
                                    ctrl.Focus();
                                    return null;
                                }
                            }
                        }
                        catch (Exception exception1)
                        {
                            ex = exception1;
                            this.lblMsg.Text = "输入的时间格式不正确！";
                            ctrl.Focus();
                            return null;
                        }
                    }
                    else if (ctrl.ID == "txtExpiryDate")
                    {
                        try
                        {
                            if (!string.IsNullOrEmpty(temp.Trim()))
                            {
                                CS00003 = new DateTime();
                                if (DateTime.Parse(temp) != CS00003)
                                {
                                    receiptLotInfo.ExpiryDate = DateTime.Parse(temp);
                                }
                                else
                                {
                                    this.lblMsg.Text = "输入的时间格式不正确！";
                                    ctrl.Focus();
                                    return null;
                                }
                            }
                        }
                        catch (Exception exception2)
                        {
                            ex = exception2;
                            this.lblMsg.Text = "输入的时间格式不正确！";
                            ctrl.Focus();
                            return null;
                        }
                    }
                    else if (ctrl.ID == "txtExternalLot")
                    {
                        if (!string.IsNullOrEmpty(temp))
                        {
                            receiptLotInfo.ExternalLot = temp;
                        }
                        else
                        {
                            receiptLotInfo.ExternalLot = "";
                        }
                    }
                    else
                    {
                        switch (ctrl.ID.Substring(4))
                        {
                            case "1":
                                receiptLotInfo.LotAttr01 = temp;
                                break;

                            case "2":
                                receiptLotInfo.LotAttr02 = temp;
                                break;

                            case "3":
                                receiptLotInfo.LotAttr03 = temp;
                                break;

                            case "4":
                                receiptLotInfo.LotAttr04 = temp;
                                break;

                            case "5":
                                receiptLotInfo.LotAttr05 = temp;
                                break;

                            case "6":
                                receiptLotInfo.LotAttr06 = temp;
                                break;

                            case "7":
                                receiptLotInfo.LotAttr07 = temp;
                                break;

                            case "8":
                                receiptLotInfo.LotAttr08 = temp;
                                break;

                            case "9":
                                receiptLotInfo.LotAttr09 = temp;
                                break;

                            case "10":
                                receiptLotInfo.LotAttr10 = temp;
                                break;
                        }
                    }
                }
            }
            receiptLotInfo.ReceiptDate = (this.txtReceiptDate.Text.Trim() == "") ? StrUtils.FormatDate(DateTime.Now) : StrUtils.FormatDate(DateTime.Parse(this.txtReceiptDate.Text.Trim()));
            receiptLotInfo.VendorID = this.txtVendorID.Text.Trim();
            receiptDetail.ReceiptLot = receiptLotInfo;
            receiptDetail.ReceivedDate = (this.txtReceiptDate.Text.Trim() == "") ? StrUtils.FormatDate(DateTime.Now) : StrUtils.FormatDate(DateTime.Parse(this.txtReceiptDate.Text.Trim()));
            receiptDetail.SkuID = this.txtSkuID.Text;
            receiptDetail.PackID = this.txtPackID.Text;
            receiptDetail.UomID = this.ddlUomID.SelectedValue;
            receiptDetail.VendorID = this.txtVendorID.Text.Trim();
            receiptDetail.ReceivedQty = decimal.Parse(this.txtReceivedQty.Text.Trim());
            receiptDetail.ConditionCode = this.ddlFreezeCode.SelectedValue;
            receiptDetail.ReasonCode = this.ddlReasonCode.SelectedValue;
            receiptDetail.Cube = float.Parse(this.txtCube.Text.Trim()) / (Convert.ToSingle(this.txtReceivedQty.Text.Trim()) * Convert.ToSingle(this.hdnUomValue.Value));
            receiptDetail.GrossWgt = float.Parse(this.txtGrossWgt.Text.Trim()) / (Convert.ToSingle(this.txtReceivedQty.Text.Trim()) * Convert.ToSingle(this.hdnUomValue.Value));
            receiptDetail.NetWgt = float.Parse(this.txtNetWgt.Text.Trim()) / (Convert.ToSingle(this.txtReceivedQty.Text.Trim()) * Convert.ToSingle(this.hdnUomValue.Value));
            receiptDetail.FromLoc = "";
            receiptDetail.FromLpnID = receiptDetail.LpnID;
            receiptDetail.ToLoc = this.txtLoc.Text.Trim();
            receiptDetail.ToLpnID = this.txtLpnID.Text.Trim();
            receiptDetail.UpdatedBy = base.UserInfo.UserID;
            return receiptDetail;
        }

        protected void hndExpectedQty_Click(object sender, EventArgs e)
        {
            this.txtReceivedQty_TextChanged(sender, e);
        }

        private void LoadData()
        {
            base.BindData2DDLBySysCode(this.ddlFreezeCode, "ConditionCode");
            base.BindData2DDLBySysCode(this.ddlReasonCode, "HoldReason");
            this.ddlReasonCode.Items.Insert(0, "");
            base.BindData2DDLBySysCode(this.ddlStatus, "ReceiptStatus");
            if (!string.IsNullOrEmpty(base.Request.QueryString["rid"].ToString()))
            {
                string ReceiptID = base.Request.QueryString["rid"].ToString();
                this.hdnReceiptID.Value = ReceiptID;
            }
            if (!string.IsNullOrEmpty(base.Request.QueryString["from"].ToString()))
            {
                string from = base.Request.QueryString["from"].ToString();
                this.hdnFrom.Value = from;
            }
            if (!string.IsNullOrEmpty(base.Request.QueryString["rlid"].ToString()))
            {
                string LineID = base.Request.QueryString["rlid"].ToString();
                this.txtReceiptLineID.Text = LineID;
            }
            if (!string.IsNullOrEmpty(base.Request.QueryString["owner"].ToString()))
            {
                string OwnerID = base.Request.QueryString["owner"].ToString();
                this.hdnOwnerID.Value = OwnerID;
            }
            this.hdnType.Value = "Edit";
            if (!(string.IsNullOrEmpty(base.Request.QueryString["rid"]) || string.IsNullOrEmpty(base.Request.QueryString["rlid"].ToString())))
            {
                this.SetReceiptDetailInfo2Form();
            }
            if (string.IsNullOrEmpty(this.txtReceiptDate.Text.Trim()))
            {
                this.txtReceiptDate.Text = base.GetPreferenceShortDate(DateTime.Now);
            }
        }

        private string ManualReceiving()
        {
            if (this.ddlStatus.SelectedValue == "ReceivedComplete")
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("F4200_018");
                return "msg";
            }
            if (string.IsNullOrEmpty(this.txtSkuID.Text.Trim()))
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("F4200_019");
                return "msg";
            }
            if (string.IsNullOrEmpty(this.txtReceivedQty.Text.Trim()))
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("F4200_020");
                return "msg";
            }
            if (string.IsNullOrEmpty(this.txtLoc.Text.Trim()))
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("F4200_021");
                return "msg";
            }
            if (string.IsNullOrEmpty(this.txtReceiptDate.Text.Trim()))
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("F4200_022");
                return "msg";
            }
            if ((this.ddlFreezeCode.SelectedValue.ToUpper() != "OK") && string.IsNullOrEmpty(this.ddlReasonCode.SelectedValue))
            {
                this.lblMsg.Text = "请选择一项原因代码!";
                return "msg";
            }
            ReceiptDetailInfo receiptDetail = this.GetReceiptDetailInfoFromForm();
            if (receiptDetail != null)
            {
                return InboundDetailServiceClientProxy.GetInstance().ExecuteReceiving(receiptDetail);
            }
            return "";
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.LoadData();
                WMS6.Web.LoginServiceRef.PreferenceInfo preferenceInfo = base.UserInfo.Preference;
                this.hdnFormart.Value = preferenceInfo.Digits_No;
            }
            this.LotAtrributeCtrl1.LoadData(this.txtSkuID.Text.Trim(), this.hdnOwnerID.Value, this.LotAtrributeCtrl1.ClientID.ToString(), true, 4);
            this.lblMsg.Text = "";
        }

        private void SetReceiptDetailInfo2Form()
        {
            try
            {
                string receiptID = base.Request.QueryString["rid"].ToString();
                string receiptLineID = this.txtReceiptLineID.Text.Trim();
                ReceiptDetailInfo receiptDetail = InboundDetailServiceClientProxy.GetInstance().GetReceiptDetailInfoByID(receiptID, receiptLineID);
                this.SetReceiptDetailInfo2Form(receiptDetail);
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = ex.Message;
                this.lblMsg.Visible = true;
            }
        }

        private void SetReceiptDetailInfo2Form(ReceiptDetailInfo receiptDetail)
        {
            if ((receiptDetail != null) && !string.IsNullOrEmpty(receiptDetail.ReceiptID))
            {
                base.DataEntityViewState = receiptDetail;
                SkuInfo sku = BaseInfoDetailServiceClientProxy.GetInstance().GetDetailInfoByID(receiptDetail.OwnerID, receiptDetail.SkuID, "", "SKU") as SkuInfo;
                if (sku != null)
                {
                    this.txtSkuDescr.Text = sku.Descr;
                    this.txtLength.Text = base.GetPreferenceDigit(sku.Length);
                    this.txtWidth.Text = base.GetPreferenceDigit(sku.Width);
                    this.txtHeight.Text = base.GetPreferenceDigit(sku.Height);
                }
                if (!string.IsNullOrEmpty(receiptDetail.ToLoc))
                {
                    this.txtLoc.Text = receiptDetail.ToLoc;
                }
                else if (sku != null)
                {
                    ZoneInfo zoneInfo = BaseInfoServiceClientProxy.GetInstance().GetInfoByID(sku.ZoneID, "ZONE") as ZoneInfo;
                    if (zoneInfo != null)
                    {
                        this.txtLoc.Text = string.IsNullOrEmpty(zoneInfo.InLoc) ? "Stage" : zoneInfo.InLoc;
                    }
                    else
                    {
                        this.txtLoc.Text = "Stage";
                    }
                }
                else
                {
                    this.txtLoc.Text = "Stage";
                }
                base.BindUomList2DDL(this.ddlUomID, receiptDetail.PackID);
                this.txtReceiptLineID.Text = receiptDetail.ReceiptLineID.ToString();
                this.ddlStatus.SelectedValue = receiptDetail.Status;
                this.txtLpnID.Text = receiptDetail.LpnID;
                this.txtCaseID.Text = receiptDetail.CaseID;
                this.txtSkuID.Text = receiptDetail.SkuID;
                this.txtPackID.Text = receiptDetail.PackID;
                this.ddlUomID.SelectedValue = receiptDetail.UomID;
                this.hdnDefaultUom.Value = receiptDetail.UomID;
                this.txtCube.Text = base.GetPreferenceDigit((float) (receiptDetail.Cube * Convert.ToSingle(receiptDetail.ExpectedQty)));
                this.txtGrossWgt.Text = base.GetPreferenceDigit((float) (receiptDetail.GrossWgt * Convert.ToSingle(receiptDetail.ExpectedQty)));
                this.txtNetWgt.Text = base.GetPreferenceDigit((float) (receiptDetail.NetWgt * Convert.ToSingle(receiptDetail.ExpectedQty)));
                this.hdnCube.Value = receiptDetail.Cube.ToString();
                this.hdnGrossWgt.Value = receiptDetail.GrossWgt.ToString();
                this.hdnNetWgt.Value = receiptDetail.NetWgt.ToString();
                this.txtHadReceivedQty.Text = base.GetPreferenceDigit(receiptDetail.HadReceivedQty);
                if (!string.IsNullOrEmpty(receiptDetail.ConditionCode))
                {
                    this.ddlFreezeCode.SelectedValue = receiptDetail.ConditionCode;
                }
                if (!string.IsNullOrEmpty(receiptDetail.ReasonCode))
                {
                    this.ddlReasonCode.SelectedValue = receiptDetail.ReasonCode;
                }
                this.txtVendorID.Text = receiptDetail.VendorID;
                this.txtExpectedQty.Text = base.GetPreferenceDigit(receiptDetail.ExpectedQty);
                this.txtPoID.Text = receiptDetail.PoID;
                this.txtReceiptDate.Text = base.GetPreferenceShortDate(DateTime.Now);
                if (receiptDetail.ReceiptLot.ReceiptDate != new DateTime())
                {
                    this.txtReceiptDate.Text = base.GetPreferenceShortDate(receiptDetail.ReceiptLot.ReceiptDate);
                }
                else if (!string.IsNullOrEmpty(base.Request.QueryString["rdate"]))
                {
                    this.txtReceiptDate.Text = base.GetPreferenceShortDate(base.Request.QueryString["rdate"]);
                }
                this.hdnLot1.Value = receiptDetail.ReceiptLot.LotAttr01;
                this.hdnLot2.Value = receiptDetail.ReceiptLot.LotAttr02;
                this.hdnLot3.Value = receiptDetail.ReceiptLot.LotAttr03;
                this.hdnLot4.Value = receiptDetail.ReceiptLot.LotAttr04;
                this.hdnLot5.Value = receiptDetail.ReceiptLot.LotAttr05;
                this.hdnLot6.Value = receiptDetail.ReceiptLot.LotAttr06;
                this.hdnLot7.Value = receiptDetail.ReceiptLot.LotAttr07;
                this.hdnLot8.Value = receiptDetail.ReceiptLot.LotAttr08;
                this.hdnLot9.Value = receiptDetail.ReceiptLot.LotAttr09;
                this.hdnLot10.Value = receiptDetail.ReceiptLot.LotAttr10;
                this.hdnProductDate.Value = base.GetPreferenceShortDate(receiptDetail.ReceiptLot.ProduceDate);
                this.hdnExpiryDate.Value = base.GetPreferenceShortDate(receiptDetail.ReceiptLot.ExpiryDate);
                this.hdnExternal.Value = receiptDetail.ReceiptLot.ExternalLot;
                this.txtReceivedQty.Text = base.GetPreferenceDigit(((receiptDetail.ExpectedQty - receiptDetail.ReceivedQty) > 0M) ? (receiptDetail.ExpectedQty - receiptDetail.ReceivedQty) : 0M);
                this.txtReceivedQty.Focus();
                this.BindData2UomList(receiptDetail.PackID);
                List<WMS6.Web.CommonMethodServiceRef.UomList> uomList = this.ViewState["UOMLIST"] as List<WMS6.Web.CommonMethodServiceRef.UomList>;
                this.hdnUomValue.Value = base.GetUomQtyByUomList(this.ddlUomID.SelectedValue, uomList).ToString();
                this.btnSave.Enabled = string.Compare(receiptDetail.Status, "closed", true) != 0;
            }
        }

        protected void txtPackID_TextChanged(object sender, EventArgs e)
        {
            try
            {
                this.BindData2UomList(this.txtPackID.Text.Trim());
                this.txtPackID.Focus();
            }
            catch (Exception ex)
            {
                this.lblMsg.Text = ex.Message;
            }
        }

        protected void txtReceivedQty_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(this.txtExpectedQty.Text.Trim()))
                {
                    if (float.Parse(this.txtExpectedQty.Text.Trim()) > 0f)
                    {
                        this.CalcSkuWgtCube();
                    }
                    else
                    {
                        this.lblMsg.Text = base.GetGlobalMsgResource("F4100_033");
                        this.lblMsg.Visible = true;
                    }
                }
            }
            catch (Exception)
            {
                this.lblMsg.Text = base.GetGlobalMsgResource("F4100_034");
                this.lblMsg.Visible = true;
            }
            this.txtExpectedQty.Focus();
        }
    }
}

